package com.jia.train.member.controller;

import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/nacos")
@RefreshScope
public class NacosConfigController {

    public static final Logger logger = LoggerFactory.getLogger(NacosConfigController.class);

    @Value("${nacos.config.value}")
    public String configValue;

    @Resource
    // 监测集群环境信息
    private Environment environment;

    @GetMapping("/value")
    public String value() {
        logger.info("value:{} , port:{}", configValue, environment.getProperty("server.port"));
        return configValue;
    }
}
